<template>
<el-dialog title="详情"
           :close-on-click-modal="false" append-to-body
           :visible.sync="visible" class="JNPF-dialog JNPF-dialog_center" lock-scroll
           width="600px">
<el-row :gutter="15" class="">
<el-form ref="elForm" :model="dataForm" size="small" label-width="100px" label-position="right" >
    <template v-if="!loading">
            <el-col :span="24"  >
                <jnpf-form-tip-item  label="采编名称"  
 prop="projectname"  >
                        <p>{{dataForm.projectname}}</p>
                </jnpf-form-tip-item>
            </el-col>
            <el-col :span="24"  >
                <jnpf-form-tip-item  label="采编项目编码"  
 prop="projectcode"  >
                        <p>{{dataForm.projectcode}}</p>
                </jnpf-form-tip-item>
            </el-col>
            <el-col :span="24"  >
                <jnpf-form-tip-item  label="成果类型"  
 prop="achievementtype"  >
                        <p>{{dataForm.achievementtype}}</p>
                </jnpf-form-tip-item>
            </el-col>
            <el-col :span="24"  >
                <jnpf-form-tip-item  label="所属学院"  
 prop="affiliatedcollege"  >
                        <p>{{dataForm.affiliatedcollege}}</p>
                </jnpf-form-tip-item>
            </el-col>
            <el-col :span="24"  >
                <jnpf-form-tip-item  label="项目完成人"  
 prop="projectcompletionperson"  >
                        <p>{{dataForm.projectcompletionperson}}</p>
                </jnpf-form-tip-item>
            </el-col>
            <el-col :span="12"  >
                <jnpf-form-tip-item  label="项目开始时间"  
 prop="projectstart"  >
                        <p>{{dataForm.projectstart}}</p>
                </jnpf-form-tip-item>
            </el-col>
            <el-col :span="12"  >
                <jnpf-form-tip-item  label="项目结束时间"  
 prop="projectend"  >
                        <p>{{dataForm.projectend}}</p>
                </jnpf-form-tip-item>
            </el-col>
            <el-col :span="24"  >
                <jnpf-form-tip-item  label="是否启用"  
 prop="isenable"  >
                        <p>{{dataForm.isenable}}</p>
                </jnpf-form-tip-item>
            </el-col>
            <el-col :span="24"  >
                <jnpf-form-tip-item  label="封面图片"  
 prop="coverurl"  >
                        <el-link :underline="false" type="primary"
                                 @click.native="toDetail(dataForm.coverurl_id,'293732572549126981')">
                            {{dataForm.coverurl}}</el-link>
                </jnpf-form-tip-item>
            </el-col>
            <el-col :span="24"  >
                <jnpf-form-tip-item  label="视频文件"  
 prop="videourl"  >
                        <el-link :underline="false" type="primary"
                                 @click.native="toDetail(dataForm.videourl_id,'395179260593052933')">
                            {{dataForm.videourl}}</el-link>
                </jnpf-form-tip-item>
            </el-col>
            <el-col :span="24"  >
                <jnpf-form-tip-item  label="序号"  
 prop="sort"  >
                    <JnpfNumber    v-model="dataForm.sort_name"
 placeholder="数字文本"  disabled
 :step="1"  controlsPosition="bothSides"  >
                </JnpfNumber>
                </jnpf-form-tip-item>
            </el-col>
            <el-col :span="24"  >
                <jnpf-form-tip-item  label="项目简介"  
 prop="briefintroduction"  >
                        <p>{{dataForm.briefintroduction}}</p>
                </jnpf-form-tip-item>
            </el-col>
    </template>
</el-form>
    </el-row>
    <span slot="footer" class="dialog-footer">
        <el-button @click="visible = false"> 取 消</el-button>
    </span>
    <Detail v-if="detailVisible" ref="Detail" @close="detailVisible = false" />
    </el-dialog>
</template>
<script>
    import request from '@/utils/request'

    import { getConfigData } from '@/api/onlineDev/visualDev'
    import jnpf from '@/utils/jnpf'
    import Detail from '@/views/basic/dynamicModel/list/detail'
    import { thousandsFormat } from "@/components/Generator/utils/index"
    export default {
        components: { Detail},
        props: [],
        data() {
            return {
                visible: false,
                detailVisible: false,
                loading: false,

            dataForm: {
                id :'',
                            projectname : '',
                            projectcode : '',
                            achievementtype : "",
                            affiliatedcollege : [],
                            projectcompletionperson : [],
                            projectstart : '',
                            projectend : '',
                            isenable : 1,
                            coverurl : "",
                            videourl : "",
                            sort : 0,
                            briefintroduction : '',
                            iscomplete : '',
                            state : '',
            },
                        achievementtypeProps:{"label":"fullName","value":"id"  },

        }
        },
        computed: {},
        watch: {},
        created() {

        },
        mounted() {},
        methods: {
            toDetail(defaultValue, modelId) {
                if (!defaultValue) return
                getConfigData(modelId).then(res => {
                    if (!res.data || !res.data.formData) return
                    let formData = JSON.parse(res.data.formData)
                    formData.popupType = 'general'
                    this.detailVisible = true
                    this.$nextTick(() => {
                        this.$refs.Detail.init(formData, modelId, defaultValue)
                    })
                })
            },
            dataInfo(dataAll){
                let _dataAll =dataAll
                        _dataAll.projectstart = _dataAll.projectstart ? this.jnpf.toDate(Number(_dataAll.projectstart),"yyyy-MM-dd") : ''
                        _dataAll.projectend = _dataAll.projectend ? this.jnpf.toDate(Number(_dataAll.projectend),"yyyy-MM-dd") : ''
                this.dataForm = _dataAll
            },

            init(id) {
                this.dataForm.id = id || 0;
                this.visible = true;
                this.$nextTick(() => {
                    if(this.dataForm.id){
                        this.loading = true
                        request({
                            url: '/api/example/MzCompilationproject/detail/'+this.dataForm.id,
                            method: 'get'
                        }).then(res => {
                            this.dataInfo(res.data)
                            this.loading = false
                        })
                    }

                })
            },
        },
    }

</script>
